import request from '@/utils/http'
import { BaseResult, PaginationResult } from '@/types/axios'

export class GoodsService {
  // 获取商品列表
  static getGoods(params?: any) {
    return request.get<BaseResult<PaginationResult<any>>>({
      url: '/list_goods',
      params
    })
  }
  // 添加商品
  static addGoods(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/add_goods',
      data
    })
  }
  // 修改商品
  static updateGoods(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/update_goods',
      data
    })
  }
  // 删除商品
  static delGoods(id: number | string) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/del_goods',
      data: { id }
    })
  }
  // 查看商品附件列表
  static getGoodsAttach(goods_id: number | string) {
    return request.get<BaseResult<PaginationResult<any>>>({
      url: '/list_goods_attachment',
      params: { goods_id }
    })
  }
  // 添加商品附件列表
  static addGoodsAttach(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/add_goods_attachment',
      data
    })
  }
  // 修改商品附件列表
  static updateGoodsAttach(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/update_goods_attachment',
      data
    })
  }
  // 删除商品附件列表
  static delGoodsAttach(id: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/del_goods_attachment',
      data: { id }
    })
  }
}
